<template>
	<view>
		<button @click="onSetTimeCall()">单次定时器setTimeout</button>
		<button @click="onSetTimeCallxy()"type = "warn">带参数</button>
		<button @click="onTimeoutClear()">取消定时器</button>
		<button @click="onInteral()">周期打印</button>
		<button @click="onClearInter()">取消周期</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userName:'kangkang',
				password:'666',
				timeoutID:null,
				count:0
			}
		},
		methods: {
			onSetTimeCall(){
				console.log("onSetTimeout");
				//setTimeout(callack,ms,ayn[])
				//()=>{}  匿名函数
				tis.timeoutID = setTimeout(()=>{
					//延时之后要执行的代码
					console.log("我延时两秒时才会打印")
				},2000)
			},
			onSetTimeCallxy(name,pwd){
				console.log("onSetTimeCallxy-->name:"+name+",pwd:"+pwd);
				setTimeout((x)=>{
					console.log("我可以传参数了> x:"+x)
				},2000,name,pwd)
			},
			onTimeoutClear(){
				console.log("onTimeoutClear-->name:"+timeoutID)
				clearTimeout(this.timeoutID);
			},
			onInteral(){
				setInterval(()=>{
					this.cout++;
					console.log("周期打印 count:",this,count);
				},1000)
			},
			onClearInter(){
				console.log("onClearInter:",this.iteralID);
				claerInterval(this.interalID)
			}
		}
	}
</script>

<style>

</style>
